<template>
  <div class="container">
    <!-- 表格start -->
    <view id="panel">
      <view class="flex-fixed">
        <text class="fixed-text">姓名</text>
        <text class="fixed-text">员工职位</text>
        <text class="fixed-text">服务客户数</text>
        <text class="fixed-text">现金业绩</text>
        <text class="fixed-text">卡耗业绩</text>
      </view>
      <scroll-view class="table-content flex" scroll-x="true" style="width:100%;white-space: nowrap;">
        <view class="db_table" v-for="item in getworkerchanzhiList" :key="item.id">
          <text class="flex-cell db">{{item.name}}</text>
          <text class="flex-cell db">{{item.position}}</text>
          <text class="flex-cell db">{{item.fuwunum}}</text>
          <text class="flex-cell db">{{item.xjyj}}</text>
          <text class="flex-cell db">{{item.khyj}}</text>
        </view>
      </scroll-view>
    </view>
    <!-- 表格end -->
    <view id="panel2" style="margin-top:20px;">
      <view class="flex-cell th">
        <text class="flex-cell td">姓名</text>
        <text class="flex-cell td">员工职位</text>
        <text class="flex-cell td">服务客户数</text>
        <text class="flex-cell td">现金业绩</text>
        <text class="flex-cell td">卡耗业绩</text>
      </view>
      <scroll-view
        class="table-content"
        scroll-y="true"
        scroll-x="true"
        style="width:100%;height:600rpx;"
      >
        <view class="tobody">
          <view class="flex-cell tr" v-for="item in getworkerchanzhiList" :key="item.id">
            <text class="flex-cell td">{{item.name}}</text>
            <text class="flex-cell td">{{item.position}}</text>
            <text class="flex-cell td">{{item.fuwunum}}</text>
            <text class="flex-cell td">{{item.xjyj}}</text>
            <text class="flex-cell td">{{item.khyj}}</text>
          </view>
        </view>
      </scroll-view>
    </view>
  </div>
</template>

<script>
import api from '@/utils/api'
import wx from 'wx'
import moment from 'moment'
export default {
  data () {
    return {
      tableData: [{ // 模拟动态获取到的后台数据：数组对象格式
        id: 0,
        name: '姓名'
      },
      {
        id: 1,
        name: '性别'
      },
      {
        id: 2,
        name: '年龄'
      },
      {
        id: 3,
        name: '生日'
      },
      {
        id: 4,
        name: '职业'
      },
      {
        id: 5,
        name: '婚否'
      },
      {
        id: 6,
        name: '生育'
      }],
      time_start: '',
      time_end: '',
      time_end2: '',
      start_time_js: '',
      end_time_js: '',
      getworkerchanzhiList: []
    }
  },

  components: {
  },
  onLoad () {
    let year = new Date().getFullYear();
    let month = new Date().getMonth() + 1;
    let day = new Date().getDate();

    this.time_start = year + '-1-1';
    this.time_end = year + '-' + month + '-' + (day + 1);
    this.time_end2 = year + '-' + month + '-' + day;

    this.start_time_js = moment(this.time_start, 'YYYY-MM-DD').unix();
    this.end_time_js = moment(this.time_end2, 'YYYY-MM-DD').unix();
    console.log(this.end_time_js)
    this.get_info()
    this.selectshop()
  },
  methods: {
    async get_info () {
      // let shopid = wx.getStorageSync('userInfo').shopid
      const res = await api.getworkerchanzhi({ shopid: '10022', start_time_js: this.start_time_js, end_time_js: this.end_time_js });
      console.log(res)
      if (res.code === '100') {
        this.getworkerchanzhiList = res.data
      }
    },
    async selectshop () {
      let orcode = wx.getStorageSync('userInfo').orcode
      const res = await api.selectshop({ orcode: orcode });
      console.log(res)
    }
  },
  created () {
  },
  onShow () {
  },
  onReady () {
  }
}
</script>

<style scoped>
.container {
  width: 100%;
}
</style>
